package com.kaifamiao.month03.day0313;

public class Poker {
    private static  String[] suites = {"黑桃", "红桃", "草花", "方块"};
    private static  int[] faces = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    private  Card[] cards;
    /**
     * 构造器
     *
     */
    public Poker() {
        cards = new Card[52];
        for(int i = 0; i < suites.length; i++) {
            for(int j = 0; j < faces.length; j++) {
                cards[i * 13 + j] = new Card(suites[i], faces[j]);
            }
        }
    }
    /**
     * 洗牌 （随机乱序）
     *
     */
    public void shuffle() {
        for(int i = 0, len = cards.length; i < len; i++) {
            int index = (int) (Math.random() * len);
            Card temp = cards[index];
            cards[index] = cards[i];
            cards[i] = temp;
        }
    }
    public Card deal(int index) {
        return cards[index];
    }
}

